package Single_No_Cyclic_Linked_List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 阿宾
 * Date: 2024-11-05
 * Time: 15:07
 */
public class MySingleListTest {
    public static void main(String[] args) {
        //创建对象
        MySingleList mySingleList = new MySingleList();
        //创建一个固定大小的链表
        //mySingleList.createList();

        //利用头插法创建链表
        /*mySingleList.addFirst(11);
        mySingleList.addFirst(22);
        mySingleList.addFirst(33);
        mySingleList.addFirst(44);*/
        //利用尾插法创建链表
        mySingleList.addLast(10);
        mySingleList.addLast(10);
        mySingleList.addLast(10);
        mySingleList.addLast(23);
        mySingleList.addLast(100);
        mySingleList.addLast(45);
        mySingleList.display();

        //指定位置插入节点
        mySingleList.addIndex(0,10);
        mySingleList.display();

        mySingleList.addIndex(4,200);
        mySingleList.display();

        mySingleList.addIndex(3,300);

        mySingleList.addLast(10);
        mySingleList.display();
        //链表长度
        System.out.println("当前链表长度：" + mySingleList.size());
        //判断链表中是否包含指定值key
        boolean ret1 = mySingleList.contains(23);
        System.out.println(ret1);
        boolean ret2 = mySingleList.contains(100);
        System.out.println(ret2);

        /*mySingleList.remove(23);
        mySingleList.display();*/
        mySingleList.removeAllKey(10);
        mySingleList.display();


    }
}
